package Array;

public class lc367 {
    public boolean isPerfectSquare(int num) {
        if (num == 0 || num == 1) {
            return true;
        }

        int left = 0;
        int right = num + 1;
        while (left + 1 < right) {
            long m = (left + right) >>> 1;
            if (m * m  == num) {
                return true;
            } else if (m * m > num) {
                right = (int)m;
            } else {
                left = (int)m;
            }
        }
        return false;
    }
}